//
//  HomeBannerTopicNoticeCell.m
//  BaseProject
//
//  Created by 王洋 on 2021/1/15.
//  Copyright © 2021 王洋. All rights reserved.
//

#import "HomeBannerTopicNoticeCell.h"

@implementation HomeBannerTopicNoticeCell

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.notiImage pp_clipCorners:UIRectCornerAllCorners radius:self.notiImage.frame.size.height/2];
    });
}

- (void)setupInitialUI {
    
    self.backgroundColor = UIColor.clearColor;

    [self addSubview:self.notiImage];
    [self addSubview:self.notiLab];
    
    [self.notiImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(8);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(16);
    }];
    
    [self.notiLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.notiImage.mas_right).offset(8);
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];

}

- (void)fillCellWithModel:(HomeADItemEventModel *)model {
    
    self.notiLab.text = model.sellerName;
    
    if (model.index <2) {
        [self.notiImage setImage:[UIImage imageNamed:@"homeTopic_xin"]];
    } else if (model.index == 2) {
        [self.notiImage setImage:[UIImage imageNamed:@"homeTopic_jian"]];
    } else {
        [self.notiImage setImage:[UIImage imageNamed:@"homeTopic_re"]];
    }

}

- (UIImageView *)notiImage {
    if (!_notiImage) {
        _notiImage = [[UIImageView alloc] init];
        _notiImage.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _notiImage;
}

- (UILabel *)notiLab {
    if (!_notiLab) {
        _notiLab = [[UILabel alloc] init];
        _notiLab.font = [UIFont systemFontOfSize:13];
        _notiLab.text = @"调试状态，未设置文本";
        _notiLab.textColor = UIColorHex(0x333333);
    }
    return _notiLab;
}

@end
